<?php
/* @var $this GatewayController */
/* @var $model Gateway */
 
$this->breadcrumbs=array(
	'Gateways'=>array('index'),
	'GatewayMapView',
);
 
if(Yii::app()->user->name=="admin"){
	    $this->menu=array(
	    	array('label'=>'路由器信息', 'url'=>array('admin')),
			array('label'=>'创建路由器', 'url'=>array('create')),
            array('label'=>'路由器地图', 'url'=>array('gatewayMap')),
	    );
	   $buttoncolumn ='{view}{update}{delete}';
    }else{
	     $this->menu=array(
			array('label'=>'路由器信息', 'url'=>array('admin')),
	     ); 
	    $buttoncolumn ='{view}';
    } 
   Yii::app()->clientScript->registerCoreScript('jquery');
?>  
 
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=69ded0fbe1c5b68f1ddc628eb58dfbe2"></script>

<script type="text/javascript">
    $(document).ready(function(e) {
        var map = new BMap.Map("allmap");
        map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
        map.centerAndZoom("<?php echo $city?>",12);   
        <?php 
            foreach ($model as $key => $value) { ?>
            var point = new BMap.Point(<?php echo $value['lng'];?>, <?php echo $value['lat'];?>);
            addMarker(point,"<?php echo $value['address'];?>"); 
         <?php } ?>

        // 编写自定义函数,创建标注
        function addMarker(point,windowinfo){
          var marker = new BMap.Marker(point); 
          map.addOverlay(marker);
          var infoWindow1 = new BMap.InfoWindow(windowinfo); 
          marker.addEventListener("click", function(){this.openInfoWindow(infoWindow1);});
         
        }
         


    }); 
</script>

<h1><?php echo $city?>-路由器分布</h1> 
<div style="font-size: 14px;margin:10px 0 10px 0;">一共部署了<?php echo count($model);?>个设备</div> 
<div class="Action">
    <a href="<?php echo Yii::app()->request->urlReferrer; ?>"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/admin/jiantou.png" style=""></a>
</div>
<div id="allmap" style="width: 100%;height: 500px;overflow: hidden;margin:10px 0 10px 0;"></div>